<template>
  <div class="container">
    <div class="Title">控制器首字母：</div>
    <div class="Letter">
      <div v-for="(item, index) in zmArray" :key="index" class="L_box">
        <p
          @click="Temp(item)"
          class="Letter_zm"
          :class="{ active: zm === item.label }"
        >
          {{ item.label }}
        </p>
      </div>
    </div>
  </div>
</template>
<script>
let zmArray = [...Array(26).keys()].map(item => {
  return {
    value: String.fromCharCode(item + 65),
    label: String.fromCharCode(item + 65)
  };
});

export default {
  name: "letterSearch",
  props: {
    zm: {
      type: String,
      default: "A"
    },
    fun: {
      type: Function
    }
  },
  data() {
    return {
      zmArray
    };
  },
  methods: {
    Temp(item) {
      this.$emit("update:zm", item.value);
      console.log(this.fun);
      this.fun();
    }
  }
};
</script>
<style scoped>
.container {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  margin: 0;
}
.Title {
  font-size: 18px;
  padding: 0 25px;
  box-sizing: border-box;
  color: rgba(107, 107, 131);
}
.Letter {
  margin: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  width: 750px;
  height: 50px;
  /* border: 1px solid #000000; */
  flex-wrap: wrap;
}
.Letter_zm {
  width: 50px;
  height: 30px;
  color: #000;
  cursor: pointer;
  text-align: center;
}
.active {
  width: 50px;
  height: 30px;
  color: rgba(1, 134, 249);
  cursor: pointer;
  font-weight: 800;
}
</style>
